<template>
  <div class="app-container">

    <!-- 查询和其他操作 -->
    <div class="filter-container">
      <el-input v-model="listQuery.shopName" clearable class="filter-item" style="width: 200px;" placeholder="请输入门店名称"/>
      <el-input v-model="listQuery.name" clearable class="filter-item" style="width: 200px;" placeholder="请输入联系人"/>
      <el-button v-permission="['GET /admin/shop/list']" class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">查找</el-button>
      <!--
      <el-button :loading="downloadLoading" class="filter-item" type="primary" icon="el-icon-download" @click="handleDownload">导出</el-button>-->
    </div>

    <!-- 查询结果 -->
    <el-table v-loading="listLoading" :data="list" element-loading-text="正在查询中。。。" border fit highlight-current-row>

      <el-table-column align="center" label="ID" width="60px" prop="id" sortable/>

      <el-table-column align="center" label="店铺名称" prop="shopName" />

      <el-table-column align="center" label="费率" prop="rate"/>

      <el-table-column align="center" label="余额" prop="balance"/>

      <el-table-column align="center" label="冻结余额" prop="freeze"/>

      <el-table-column align="center" label="不可提现余额" prop="notCashing"/>

      <el-table-column align="center" label="提现次数" prop="cashingNum"/>

    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />


  </div>
</template>



<script>
import { listShopBalance } from '@/api/shop'
import { getToken } from '@/utils/auth'
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination

export default {
  name: 'Ad',
  components: { Pagination },
  data() {
    return {
      list: [],
      total: 0,
      listLoading: true,
      listQuery: {
        page: 1,
        limit: 20,
        name: undefined,
        shopName: undefined,
        tel: undefined
      },
      dataForm: {
        id: undefined,
        shopId: undefined,
        rate: undefined,
        balance: undefined,
        notCashing: undefined,
        freeze: undefined,
        cashingNum: undefined,
        deliveryStatus: undefined
      },
      dialogFormVisible: false,
      dialogStatus: '',
      textMap: {
        update: '编辑',
        create: '创建'
      },
      rules: {
        name: [
          { required: true, message: '联系人不能为空', trigger: 'blur' }
        ],
        shopName: [
          { required: true, message: '门店名称不能为空', trigger: 'blur' }
        ],
        address: [{ required: true, message: '门店地址不能为空', trigger: 'blur' }],
        tel: [{ required: true, message: '联系人号码不能为空', trigger: 'blur' }],
        picUrl: [{ required: true, message: '门店图片不能为空', trigger: 'blur' }]
      },
      downloadLoading: false
    }
  },
  computed: {
    headers() {
      return {
        'X-Litemall-Admin-Token': getToken()
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.listLoading = true
      listShopBalance(this.listQuery)
        .then(response => {
          this.list = response.data.data.list
          this.total = response.data.data.total
          this.listLoading = false
        })
        .catch(() => {
          this.list = []
          this.total = 0
          this.listLoading = false
        })
    },
    handleFilter() {
      this.listQuery.page = 1
      this.getList()
    },

  }
}
</script>
<style>
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #20a0ff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 120px;
  height: 120px;
  line-height: 120px;
  text-align: center;
}
.avatar {
  width: 145px;
  height: 145px;
  display: block;
}
</style>
